file->string   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/scheme.xtm

Implementation

;; this is incredibly slow! use sys:slurp-file instead
(define file->string
  (lambda (path)
    (let ((in (open-input-file path))
          (out (make-string 0)))
      (if in
          (let loop ((char (read-char in)))
            (if (not (eof-object? char))
                (begin (emit (string char) out)
                       (loop (read-char in)))
                (begin (close-port in)
                       out)))
          (begin (print-with-colors 'red 'default #t
                                    (print "Error opening file: "))
                 (print path "\n")
                 #f)))))


Back to Index